package com.java.mybatis.service.impl;

import com.java.mybatis.dao.AnnouncementDao;
import com.java.mybatis.entity.Announcement;
import com.java.mybatis.service.AnnouncementService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (Announcement)表服务实现类
 *
 * @author makejava
 * @since 2021-01-15 17:10:28
 */
@Service("announcementService")
public class AnnouncementServiceImpl implements AnnouncementService {
    @Resource
    private AnnouncementDao announcementDao;

    /**
     * 通过ID查询单条数据
     *
     * @param announcementId 主键
     * @return 实例对象
     */
    @Override
    public Announcement queryById(Integer announcementId) {
        return announcementDao.queryById(announcementId);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<Announcement> queryAllByLimit(int offset, int limit) {
        return this.announcementDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param announcement 实例对象
     * @return 实例对象
     */
    @Override
    public Announcement insert(Announcement announcement) {
        this.announcementDao.insert(announcement);
        return announcement;
    }

    /**
     * 修改数据
     *
     * @param announcement 实例对象
     * @return 实例对象
     */
    @Override
    public int updateAnnouncementById(Announcement announcement ) {
        return this.announcementDao.updateAnnouncementById(announcement);
    }
    /**
     * 通过主键删除数据
     *
     * @param announcementId 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer announcementId) {
        return this.announcementDao.deleteById(announcementId) > 0;
    }
    /**
     * 查询所有公告信息
     * @return 序列对象
     */
    @Override
    public List<Announcement> selectAllAnnouncement() {
        return announcementDao.selectAllAnnouncement();
    }
    /**
     * 新增所有列的方法
     * @return 受影响行数
     */
    @Override
    public Integer insertAnnouncement(Announcement announcement) {
        return announcementDao.insertAnnouncement(announcement);
    }
    /**
     * 禁用的方法
     * @return 受影响行数
     */
    @Override
    public void upAnnouncementDown(Integer id) throws Exception {
      announcementDao.upAnnouncementDown(id);
    }
}